<script type="text/javascript">
function delF() {
	if(confirm('คุณต้องการลบข้อมูลที่เลือกไว้หรือไม่')==true) {
	var frm = document.forms["myForm"];
	frm.action = "<?=site_url()?>TutorSearch/delete";
	frm.submit();
	}
}
</script>
<div id="mainContent">
<form  name="myForm" id="myForm" method="post" action="<?=site_url()?>TutorSearch/search">
<table width="550px" align="center" cellpadding="2" cellspacing="2" style="border: 1px solid #0000FF; background-color: #FFFFFF">
  <col width="170px" />
  <col width="*" />
  <tr bgcolor="#000974">
    <td colspan="2" align="left" bgcolor="#000974" style="color:#FFFFFF;"><label>.:: ค้นหาประวัติครู </label></td>
  </tr>
  <tr>
    <td align="right"><label>ชื่อ หรือ นามสกุล (ไทย)</label></td>
    <td align="left">
      <input name="txtName" type="text" id="txtName" size="40" value="<?php if(isset($keyword)) echo $keyword; ?>" />    </td>
  </tr>
  <tr>
    <td align="right"><label>ชื่อ หรือ นามสกุล (อังกฤษ)</label></td>
    <td align="left">
      <input name="txtNameEn" type="text" id="txtNameEn" size="40" value="<?php if(isset($keyword)) echo $keyword; ?>" />    </td>
  </tr>
  <tr>
    <td align="right"><label>ชื่อเล่น</label></td>
    <td align="left">
      <input name="txtNickName" type="text" id="txtNickName" size="40" value="<?php if(isset($keyword)) echo $keyword; ?>" />    </td>
  </tr>
  <?php if($this->session->userdata('profile') == 'Administrator') { ?>
  <tr>
    <td align="right"><label>วิชาที่สอนได้</label></td>
    <td align="left">
    	<input name="selSubjet" type="text" id="selSubjet" size="40" /> 
    </td>
  </tr>
   <tr>
    <td align="right" valign="top"><label>โรงเรียนที่สังกัด</label></td>
    <td align="left">
    	<?php
			foreach ($schoolList as $row) {
			    echo ' <input type="checkbox" name="chkSchool[]" value="'.$row->school_id .'"';
			    if(isset($schoolListCheck) && in_array($row->school_id, $schoolListCheck)) {
			    	echo ' checked="checked" ';
			    } 
			    echo ' /> '.$row->school_name.' ';
			}
        ?>
    </td>
  </tr>
  <tr>
    <td align="right"><label>สถานที่สามารถไปสอนได้</label></td>
    <td align="left">
    	<input name="txtLocation" type="text" id="txtLocation" size="40" value="<?php if(isset($keyword)) echo $keyword; ?>" />
    </td>
  </tr>
  <?php } ?>
  <tr>
    <td align="right"><label>เบอร์โทรศัพท์</label></td>
    <td align="left">
    	<input name="txtTel" type="text" id="txtTel" size="40" value="<?php if(isset($keyword)) echo $keyword; ?>" />
    </td>
  </tr>
  <tr>
    <td align="right"><label>อีเมล์</label></td>
    <td align="left">
    	<input name="txtEmail" type="text" id="txtEmail" size="40" value="<?php if(isset($keyword)) echo $keyword; ?>" />
    </td>
  </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td align="left"><input type="submit" name="button" id="button" value="ค้นหาข้อมูล" /></td>
  </tr>
  <tr style="height:10px;">
    <td colspan="2"></td>
  </tr>
</table>

<br/>
<table width="1000px" align="center" cellpadding="0" cellspacing="2" style="border: 1px solid #0000FF; background-color: #FFFFFF">
 	<tr bgcolor="#000974">
 		<?php
 			if($this->session->userdata('profile') == 'Administrator') {
 				echo '<td width="50px" align="center"><input type="button" value=" ลบ " onclick="delF()" ></td>';		
 			}	?>
		<td><div align="center" style="color:#FFFFFF;"><strong>ชื่อ</strong></div></td>
		<?php if($this->session->userdata('profile') == 'employee') {
			echo '<td><div align="center" style="color:#FFFFFF;"><strong>ชื่อเล่น</strong></div></td>';
		} ?>
      	<td><div align="center" style="color:#FFFFFF;"><strong>วิชาที่สอนได้</strong></div></td>
      	<?php if($this->session->userdata('profile') == 'Administrator') {
        	echo '<td><div align="center" style="color:#FFFFFF;"><strong>ร.ร. </strong></div></td>';
      	} ?>
        <td><div align="center" style="color:#FFFFFF;"><strong>สถานที่สามารถไปสอนได้ </strong></div></td>
        <?php if($this->session->userdata('profile') == 'Administrator') { ?>
        <td><div align="center" style="color:#FFFFFF;"><strong>มือถือ </strong></div></td>
        <td><div align="center" style="color:#FFFFFF;"><strong>เครือข่าย </strong></div></td>
        <td><div align="center" style="color:#FFFFFF;"><strong>อีเมล์ </strong></div></td>
        <?php } ?>
        <td width="100"><div align="center" style="color:#FFFFFF;"><strong>วันที่ลงข้อมูล </strong></div></td>
        <td width="80"><div align="center" style="color:#FFFFFF;"><strong>ผู้ลงข้อมูล </strong></div></td>
        <td width="90px"><div align="center" style="color:#FFFFFF;"><strong>รายละเอียด </strong></div></td>
 	</tr>
 	
 	<?php 
 		$i = 1; $monthTh = array("","ม.ค.","ก.พ. ","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
 		if(isset($result)) {
 			foreach ($result as $row) {
 				echo '<tr align="left"';
				if($i % 2 == 0) {
					echo ' bgColor=#c6e2ff ';
				}
				$i++;
				echo '>'; 
 			?>
 				<?php
		 			if($this->session->userdata('profile') == 'Administrator') { ?>
		 				<td align="center"><input type="checkbox" name="txtDel[]" value="<?=$row->tutor_id?>" > </td>	
		 		<?php }?>
	 			<td><?php echo $row->first_name_th;
	 				if($this->session->userdata('profile') == 'Administrator') {
	 					echo ' ' . $row->last_name_th;}?></td>
	 			<?php if($this->session->userdata('profile') == 'employee') {
			echo '<td>'.$row->nick_name.'</td>';
		} ?>
	 			<td>
				<?php
				if($row->teach01_subject != null OR $row->teach01_subject !=''){
				 		echo $row->teach01_subject;
						if($row->teach01_class != null OR $row->teach01_class !=''){
							echo '('. $row->teach01_class .')<br />';
						}else if($row->teach_other_1 != null OR $row->teach_other_1 !=''){
							echo '(' .$row->teach_other_1 .')<br />';
						}
					}
		                        if($row->teach02_subject != null OR $row->teach02_subject !=''){
				 		echo $row->teach02_subject;
						if($row->teach02_class != null OR $row->teach02_class !=''){
							echo '('. $row->teach02_class .')<br />';
						}else if($row->teach_other_2 != null OR $row->teach_other_2 !=''){
							echo '(' .$row->teach_other_2 .')<br />';
						}
					}
		                        if($row->teach03_subject != null OR $row->teach03_subject !=''){
				 		echo $row->teach03_subject;
						if($row->teach03_class != null OR $row->teach03_class !=''){
							echo '('. $row->teach03_class .')<br />';
						}else if($row->teach_other_3 != null OR $row->teach_other_3 !=''){
							echo '(' .$row->teach_other_3 .')<br />';
						}
					}
		                        if($row->teach04_subject != null OR $row->teach04_subject !=''){
				 		echo $row->teach04_subject;
						if($row->teach04_class != null OR $row->teach04_class !=''){
							echo '('. $row->teach04_class .')<br />';
						}else if($row->teach_other_4 != null OR $row->teach_other_4 !=''){
							echo '(' .$row->teach_other_4 .')<br />';
						}
					}
		                        if($row->teach05_subject != null OR $row->teach05_subject !=''){
				 		echo $row->teach05_subject;
						if($row->teach05_class != null OR $row->teach05_class !=''){
							echo '('. $row->teach05_class .')<br />';
						}else if($row->teach_other_5 != null OR $row->teach_other_5 !=''){
							echo '(' .$row->teach_other_5 .')<br />';
						}
					}
		                        if($row->teach06_subject != null OR $row->teach06_subject !=''){
				 		echo $row->teach06_subject;
						if($row->teach06_class != null OR $row->teach06_class !=''){
							echo '('. $row->teach06_class .')<br />';
						}else if($row->teach_other_6 != null OR $row->teach_other_6 !=''){
							echo '(' .$row->teach_other_6 .')<br />';
						}
					}
				?>
				</td>
	 			<?php if($this->session->userdata('profile') == 'Administrator') {
	 				echo '<td>'.$row->school_name.'</td>';
	 			}
				?>
	 			<td>
				<?php echo $row->teach_area;?></td>
	 			<?php if($this->session->userdata('profile') == 'Administrator') { ?>
		        <td><?php echo $row->mobile01;?></td>
		        <td><?php echo $row->mobile01_network;?></td>
		        <td><?php echo $row->email;?></td>
		        <?php } ?>
	 			<td><?=strftime("%d",strtotime($row->update_date)) . ' ' . $monthTh[ (int) strftime("%m",strtotime($row->update_date))] .' ' .strftime("%Y",strtotime($row->update_date))?></td>
		        <td><?=$row->update_by?></td>
	 			<td><a href="<?=site_url()?>TutorInfo/detail/<?=$row->tutor_id?>" > 
		            <div align="center"> <img border="0" src="<?=base_url()?>images/detail_b.png" onmouseout="toBlack(this);" onmouseover="toColor(this);" width="25" height="25" /> </div></a>	
		        </td>
	 	  	</tr>		
 	<?php 	}
 		}
 	?>
</table>
</form>
</div>

<script type="text/javascript">
	function toBlack(obj) {
		obj.src = '<?=base_url()?>images/detail_b.png';
	}
	function toColor(obj) {
		obj.src = '<?=base_url()?>images/detail.png';
	}
</script>